package com.zhanglijie.theory.sigleThreadedExecutor;

import lombok.Data;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/7/22 0022 0:17
 */
public class SafeGate {
    private int no;
    private String name;
    private String address;
    public SafeGate(){}
    public synchronized void  pass(String name,String add){
        no++;
        this.name = name;
        this.address = add;
        check();
    }
    public void check(){
        if (name.charAt(0) != address.charAt(0)) {
            System.out.println("校验出错，"+toString());
        }
    }

    @Override
    public synchronized String toString() {
        return "SafeGate{" + "no=" + no + ", name='" + name + '\'' + ", address='" + address + '\'' + '}';
    }
}
